# -*- coding: utf-8 -*-
from utils.operators.spark_submit import SparkSubmitOperator

from jms.dwd.tab.dwd_barscan_collect_dt import jms_dwd__dwd_barscan_collect_dt
from jms.dwd.tab.dwd_barscan_centerarrival_dt import jms_dwd__dwd_barscan_centerarrival_dt
from jms.dwd.tab.dwd_barscan_centersend_dt import jms_dwd__dwd_barscan_centersend_dt
from jms.dwd.tab.dwd_barscan_sign_dt import jms_dwd__dwd_barscan_sign_dt
from jms.dwd.tab.dwd_barscan_taking_dt import jms_dwd__dwd_barscan_taking_dt
from jms.dwd.tab.dwd_barscan_warehousing_dt import jms_dwd__dwd_barscan_warehousing_dt
from jms.dwd.oms.dwd_oms_order_dt import jms_dwd__dwd_oms_order_dt
from jms.ods.tab.tab_statistics  import jms_ods__tab_statistics
from jms.ods.lmdm.yl_lmdm_sys_network_expand import jms_ods__yl_lmdm_sys_network_expand

jms_dm__dm_sign_aging_summary_dt = SparkSubmitOperator(
    task_id='jms_dm__dm_sign_aging_summary_dt',
    email=['wangmenglei@jtexpress.com','yl_bigdata@yl-scm.com'],
    pool_slots=4,
    # depends_on_past=True,  # 如果任务依赖于前一天的同名任务，则将 depends_on_past 设为 True
    task_concurrency=1,  # 如果任务不支持并发，则将 task_concurrency 设为 1
    name='jms_dm__dm_sign_aging_summary_dt_{{ execution_date | date_add(1) | cst_ds }}',  # yarn 任务名称
    driver_memory='2G',
    executor_memory='8G',
    executor_cores=4,
    num_executors=10,
    conf={'spark.executor.memoryOverhead'         : 2048,
          'spark.core.connection.ack.wait.timeout': 300,
          'spark.default.parallelism'             : 600,
          'spark.locality.wait'                   : 60,
          },
    #jars='hdfs:///user/spark/work/dm/dm_sign_aging_summary/common-1.0-SNAPSHOT.jar',  # 依赖 jar 包
    jars='hdfs:///scheduler/jms/spark/chk/dm_sign_aging_summary/common-1.0-SNAPSHOT.jar',  # 依赖 jar 包
    java_class='com.yunlu.bigdata.jobs.export.ExportSignedDurationData',  # spark 主类
    #application='hdfs:///user/spark/work/dm/dm_sign_aging_summary/original-jobs-1.0-SNAPSHOT.jar',  # spark jar 包
    application='hdfs:///scheduler/jms/spark/chk/dm_sign_aging_summary/original-jobs-1.0-SNAPSHOT.jar',  # spark jar 包
    application_args=['{{ execution_date | date_add(1) | cst_ds }}'],  # 参数dt 运行当天日期
)

# 设置依赖
jms_dm__dm_sign_aging_summary_dt << [jms_ods__yl_lmdm_sys_network_expand,
                                     jms_dwd__dwd_barscan_collect_dt,
                                     jms_dwd__dwd_barscan_warehousing_dt,
                                     jms_dwd__dwd_barscan_sign_dt,
                                     jms_dwd__dwd_barscan_taking_dt,
                                     jms_dwd__dwd_barscan_centersend_dt,
                                     jms_dwd__dwd_barscan_centerarrival_dt,
                                     jms_ods__tab_statistics,
                                     jms_dwd__dwd_oms_order_dt,
                                     ]
